package com.shqcjd.siemensglass.adapter;

import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.siemensglass.MyApp;
import com.shqcjd.siemensglass.R;
import com.shqcjd.siemensglass.bean.UserStatusBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 用户状态
 * Created by sy on 2018/11/26.
 */

public class UserStatusAdapter extends BaseQuickAdapter<UserStatusBean,UserStatusAdapter.ViewHolder> {

    public UserStatusAdapter(@Nullable List<UserStatusBean> data) {
        super(R.layout.item_user_status, data);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    protected void convert(ViewHolder helper, UserStatusBean item) {
        helper.tv_name.setText(item.name);
        switch (item.status) {
            case 1: //空闲:
                helper.tv_status.setText("空闲");
                helper.tv_status.setTextColor(ContextCompat.getColor(MyApp.applicationContext,R.color.green));
                break;
            case 2: //忙碌
                helper.tv_status.setText("忙碌");
                helper.tv_status.setTextColor(ContextCompat.getColor(MyApp.applicationContext,R.color.yellow));
                break;
            case 3: //离线
                helper.tv_status.setText("离线");
                helper.tv_status.setTextColor(ContextCompat.getColor(MyApp.applicationContext,R.color.red));
                break;
        }
    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.tv_name)
        TextView tv_name;
        @BindView(R.id.tv_status)
        TextView tv_status;
        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
